<table  id="report" class="fl table table-striped table-bordered">
	<form action="" id="reportForm">
		<tr class="active">
			<td>日期区间</td>
			<td colspan="2" class="tal">
				<div>
				   	<label>日期&nbsp;<input type="datebox" class="easyui-datebox" autocomplete="off" placeholder="" name="startTime" id="startTime" style="width:94px;">
				   		<span class="glyphicon glyphicon-resize-horizontal"></span>
				   	</label>
				   	<label><input type="datebox" class="easyui-datebox" autocomplete="off" placeholder="" name="endTime" id="endTime" style="width:94px;"></label>
					<button class="btn btn-danger report_date" data="today" type="submit">今日</button>
					<button class="btn btn-danger report_date" data="yesterday" type="submit">昨日</button>
					<button class="btn btn-danger report_date" data="tomorrow" type="submit">明日</button>
					<button class="btn btn-danger report_date" data="theweek" type="submit">本期</button>
					<button class="btn btn-danger report_date" data="lastweek" type="submit">上期</button>
				</div>
			</td>
		</tr>
		<tr>
			<td>报表类型</td>
			<td class="tal" colspan="2">
				<div class="radio">
				   <label><input type="radio" value="A" name="report_type" checked>交收报表</label>
				</div>
		      	<div class="radio">
				   <label><input type="radio" value="B" name="report_type">分类报表</label>
				</div>
			</td>
		</tr>
		<tr>
			<td colspan="3">
				<button type="submit" class="btn btn-danger search" onClick="accountSubmit()">查询</button>
			</td>
		</tr>
	</form>
	<tr class="fwb">
		<td>日期</td>
		<td>今日</td>
		<td>昨日</td>
	</tr>
	<tr>
		<td>已结算</td>
		<td class="c_red">30</td>
		<td class="c_red">0</td>
	</tr>
	<tr>
		<td>未结算</td>
		<td class="c_red">0</td>
		<td class="c_red">21</td>
	</tr>
	<tr>
		<td>输赢</td>
		<td class="c_red">0</td>
		<td class="c_red">21</td>
	</tr>
	<tr>
		<td>盈利最多的彩票</td>
		<td class="c_red">时时彩</td>
		<td class="c_red">快8</td>
	</tr>
	<tr>
		<td>亏损最多彩票</td>
		<td class="c_red">PK10</td>
		<td class="c_red">时时彩</td>
	</tr>
	
</table>
<table class="fl table table-bordered" id="qishu">
	<tr class="active">
		<td colspan="2">2017年月账期数</td>
		<td colspan="2">2016年月账期数</td>
	</tr>
	<tr>
		<td>2017年第一期</td>
		<td>2017-01-01~2017-01-31</td>
		<td>2016年第一期</td>
		<td></td>
	</tr>
	<tr>
		<td>2017年第二期</td>
		<td>2017-02-01~2017-02-28</td>
		<td>2016年第二期</td>
		<td></td>
	</tr>
	<tr>
		<td>2017年第三期</td>
		<td>2017-03-01~2017-03-31</td>
		<td>2016年第三期</td>
		<td></td>
	</tr>
	<tr>
		<td>2017年第四期</td>
		<td>2017-04-01~2017-04-30</td>
		<td>2016年第四期</td>
		<td></td>
	</tr>
	<tr>
		<td>2017年第五期</td>
		<td>2017-05-01~2017-05-31</td>
		<td>2016年第五期</td>
		<td></td>
	</tr>
	<tr>
		<td>2017年第六期</td>
		<td>2017-06-01~2017-06-30</td>
		<td>2016年第六期</td>
		<td></td>
	</tr>
	<tr>
		<td>2017年第七期</td>
		<td>2017-07-01~2017-07-31</td>
		<td>2016年第七期</td>
		<td></td>
	</tr>
	<tr>
		<td>2017年第八期</td>
		<td>2017-08-01~2017-08-31</td>
		<td>2016年第八期</td>
		<td></td>
	</tr>
	<tr>
		<td>2017年第九期</td>
		<td>2017-09-01~2017-09-30</td>
		<td>2016年第九期</td>
		<td></td>
	</tr>
	<tr>
		<td>2017年第十期</td>
		<td>2017-10-01~2017-10-31</td>
		<td>2016年第十期</td>
		<td></td>
	</tr>
	<tr>
		<td>2017年第十一期</td>
		<td>2017-11-01~2017-11-30</td>
		<td>2016年第十一期</td>
		<td></td>
	</tr>
	<tr>
		<td>2017年第十二期</td>
		<td>2017-12-01~2017-12-31</td>
		<td>2016年第十二期</td>
		<td></td>
	</tr>
	 
</table>
<script type="text/javascript">
	// 默认当前时间
	 $(document).ready(function () {
	 	var date = get_dates('today');
//	 	console.log(date)
	 	$('#startTime').val(date[0]);
	 	$('#endTime').val(date[1]);
	 })

    $(".report_date").click(function() {
    	
        var dates = get_dates($(this).attr('data'));
//        console.log(dates);
        $('#startTime').datebox("setValue", dates[0]);
        $('#endTime').datebox("setValue", dates[1]);
    });

    function get_dates(type)
    {
        var startdate;
        var enddate;
        var now = new Date(); //当前日期
        var nowDayOfWeek = now.getDay(); //今天本周的第几天
        var nowDay = now.getDate(); //当前日
        var nowMonth = now.getMonth(); //当前月
        var nowYear = now.getYear(); //当前年
        nowYear += (nowYear < 2000) ? 1900 : 0;

        switch(type) {
            case 'yesterday':
                startdate = format_date(new Date(nowYear, nowMonth, nowDay - 1));
                enddate = format_date(new Date(nowYear, nowMonth, nowDay));
                break;
            case 'tomorrow':
                startdate = format_date(new Date(nowYear, nowMonth, nowDay + 1));
                enddate = format_date(new Date(nowYear, nowMonth, nowDay));
                break;
            case 'theweek':
                startdate = format_date(new Date(nowYear, nowMonth, nowDay - nowDayOfWeek+1));
                enddate = format_date(new Date(nowYear, nowMonth, nowDay));
                break;
            case 'lastweek':
                startdate = format_date(new Date(nowYear, nowMonth, nowDay - nowDayOfWeek-6));
                enddate = format_date(new Date(nowYear, nowMonth, nowDay-nowDayOfWeek));
                break;
            case 'today':
                startdate = format_date(new Date(nowYear, nowMonth, nowDay));
                enddate = format_date(new Date(nowYear, nowMonth, nowDay));
                break;
            default:
                startdate = enddate = format_date(new Date()); //当前日期
        }

        return [startdate, enddate];
    }

    function format_date(date) {
        var myyear = date.getFullYear();
        var mymonth = date.getMonth()+1;
        var myweekday = date.getDate();

        if(mymonth < 10){
            mymonth = "0" + mymonth;
        }
        if(myweekday < 10){
            myweekday = "0" + myweekday;
        }
        return (myyear+"-"+mymonth + "-" + myweekday);
    }

    // 点击查询，跳转页面
    function accountSubmit(){ 
	  var submitType = $("input[name='report_type']:checked").val();
	  if(submitType=='A'){
	    Core.addTab('交收报表', 'report/settlement_report');
	  }else if(submitType=='B'){
		Core.addTab('分类报表', 'report/classify_report');
		}
	}
</script>